import Vue from 'vue'
import Router from 'vue-router'


/* import Home from '@/pages/Home/Home'
import Recommend from '@/pages/Recommend/Recommend'
import Search from '@/pages/Search/Search'
import Chat from '@/pages/Chat/Chat'
import Me from '@/pages/Me/Me'
import Login from "@/pages/Login/Login";
 */

const Home = () => import ('@/pages/Home/Home')
const Recommend = () => import ('@/pages/Recommend/Recommend')
const Search = () => import ('@/pages/Search/Search')
const Chat = () => import ('@/pages/Chat/Chat') 
const Me = () => import ('@/pages/Me/Me')
const Login = () => import ('@/pages/Login/Login')
const Register  = () => import ('@/pages/Register/Register')
const Verified  = () => import ('@/pages/Verified/Verified')


// 二级路由 
import Hot from '@/pages/Home/Children/hot/Hot'
import Box from "@/pages/Home/Children/Box"
import Dress from "@/pages/Home/Children/Dress"
import Ele from "@/pages/Home/Children/Ele"
import Food from "@/pages/Home/Children/Food"
import General from "@/pages/Home/Children/General" 
import Man from "@/pages/Home/Children/Man" 
import Mbaby from "@/pages/Home/Children/Mbaby"
import Shirt from "@/pages/Home/Children/Shirt"

import Meidentity from "@/pages/Me/Meidentity";
import Mesetting from "@/pages/Me/MeSetting";
import About from "@/pages/Me/About";
import Userdetail from "@/pages/Me/UserDetail"; 
import Xieyi from "@/pages/Xieyi/Xieyi";
import Xieyi1 from "@/pages/Xieyi1/Xieyi1"; 

import Contractlist from "@/pages/Home/Contractlist";
import Contractdetail from "@/pages/Home/Contractdetail";
import Loading from "@/pages/Me/Loading"; 
Vue.use(Router)

// 解决重复点击路由报错的BUG
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) { 
  return originalPush.call(this, location).catch((err) => err)
}

export default new Router({
  // hash模式：地址栏包含#，#之后的不被获取
  // history模式：具有对url历史进行修改的功能
  mode: 'history',
  routes: [
    {
      path: "/Home",
      component: Home,
      meta: { ButtonRouterLink: true }
    },
    // {
    //   path: "/recommend",
    //   component: Recommend,
    //   meta: { ButtonRouterLink: true }
    // },
    // {
    //   path: "/search",
    //   component: Search,
    //   meta: { ButtonRouterLink: true }
    // },
    // {
    //   path: "/chat",
    //   component: Chat,
    //   meta: { ButtonRouterLink: true }
    // },
    {
      path: "/me",
      component: Me,
      meta: { ButtonRouterLink: true }
    },
    {
      path: "/login",
      component: Login
    },
    {
      path: '/register',
      component: Register
    },
    {
      path: "/verified",
      component: Verified
    },
    {
      path: "/identity",
      component: Meidentity
    },
    {
      path: "/setting",
      component: Mesetting 
    },
    {
      path: "/about",
      component: About 
    },
    {
      path: "/loading",
      component: Loading 
    },
    {
      path: "/userdetail",
      component: Userdetail
    },
    {
      path: "/contractlist",
      component: Contractlist
    },
    {
      path: "/contractdetail",
      component: Contractdetail
    },
    {
      path: "/xieyi",
      component: Xieyi
    },
    {
      path: "/xieyi1", 
      component: Xieyi1
    },
    {
      path: "/",
      redirect: "/login"
    }
  ]
});
